package com.soft.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.soft.entity.Dept;

import com.soft.mapper.DeptMapper;
@Service
public class DeptService {
	@Autowired
	private DeptMapper deptMapper;
	public List<Dept> queryAll(){
		List<Dept> deptList = deptMapper.selectList(null);
		return deptList;
	}
	public List<Dept> queryByLoc(String deptLoc){
		QueryWrapper<Dept> qw = new QueryWrapper<>();
		qw.eq("dept_loc", deptLoc);
		List<Dept> deptList = deptMapper.selectList(qw);
		return deptList;
	}
	public int insertOne(String deptName,String deptLoc){
		Dept dept = new Dept();
		dept.setDeptName(deptName);
		dept.setDeptLoc(deptLoc);
		int num = deptMapper.insert(dept);
		return num;
	}
	public int deleteById(String deptno) {
		Dept dept = new Dept();
		dept.setDeptno(deptno);
		int num = deptMapper.deleteById(dept);
		return num;
	}
	public int updateOne(String deptno,String deptName,String deptLoc) {
		Dept dept = new Dept();
		dept.setDeptno(deptno);
		dept.setDeptName(deptName);
		dept.setDeptLoc(deptLoc);
		int num = deptMapper.updateById(dept);
		return num;
	}
}
